#!/usr/bin/python
import requests
import re
import urllib.request
from proxy.Manager.ProxyManager import ProxyManager
from proxy.Schedule.ProxyValidSchedule import validHttpUsefulProxy,validHttpsUsefulProxy
class Test:
    # proxy = "111.13.7.118"
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
    }
    def proxyip(self):
        url = "http://1212.ip138.com/ic.asp"
        http = "117.78.35.194:3128"
        # print(proxy)
        # http = ProxyManager().gethttp()
        proxies = {"http": "http://{proxy}".format(proxy=http)}
        print(proxies)
        res = requests.get(url, headers=self.headers, proxies=proxies, timeout=30, verify=False)
        print(res.status_code)
        print(res.content.decode("gb2312"))

        # urls = "https://www.baidu.com"
        # https = "115.159.252.79:8080"
        # proxies = {"https": "https://{proxy}".format(proxy=https)}
        # print(proxies)
        # res = requests.get(urls, headers=self.headers, proxies=proxies, timeout=30, verify=False)
        # print(res.status_code)
        # print(res.content)

    def test(self):
        # print(validHttpUsefulProxy(ProxyManager().gethttp()))
        print(validHttpsUsefulProxy(ProxyManager().gethttps()))

if __name__ == '__main__':
    p = Test()
    p.proxyip()
    # p.test()